package com.atguigu.tingshu.user.admin;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.user.service.UserInfoService;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import com.atguigu.tingshu.vo.user.UserPaidRecordVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "用户管理接口")
@RestController
@RequestMapping("admin/user/userInfo")
@SuppressWarnings({"all"})
public class UserInfoController {

	@Autowired
	private UserInfoService userInfoService;

	@Operation(summary = "根据用户id获取用户信息")
	@GetMapping("getUserInfoVo/{userId}")
	public Result<UserInfoVo> getUserInfoVo(@PathVariable Long userId) {
		// 获取用户信息
		UserInfoVo userInfoVo = userInfoService.getUserInfoVoByUserId(userId);
		return Result.ok(userInfoVo);
	}

	@Operation(summary = "处理用户购买记录")
	@PostMapping("/savePaidRecord")
	public Result savePaidRecord(@RequestBody UserPaidRecordVo userPaidRecordVo){
		// 调用服务层方法.
		userInfoService.savePaidRecord(userPaidRecordVo);
		// 默认返回
		return Result.ok();
	}

}

